Skip to content

Unify base-path and relative-path handling across all filesystem adap… - #14

Open
attermann wants to merge 1 commit into
masterfrom
unified_paths
Open

attermann wants to merge 1 commit into
masterfrom
unified_paths

Conversation

@attermann

@attermann attermann commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

…ters

Every adapter now resolves paths the same way: a path is always relative to the adapter's root ("/a", "./a" and "a" are the same file) and the base path says where that root is. An empty base selects the backend's default root: the current directory on native hosts, the fallback mount on ESP32, the filesystem root elsewhere.

  • Add allocation-free Path.h (normalize/join/copy_base/persistent_mount)
  • Honor the base path in the POSIX and stdio adapters
  • Accept relative paths on the ESP32 LittleFS/SPIFFS/SD adapters, which also stops init()'s write check from reformatting on every boot
  • Copy base paths into fixed adapter buffers and keep the LittleFS mount point in static storage, since Arduino's FS layer keeps the pointer
  • Native behavior change: with the default base, absolute paths now resolve under the current directory; pass "/" for host-absolute paths

Problem

Solution

Compatibility

  • No change to the on-disk format (or: a compatibility/migration path is described below and added to CHANGELOG)
  • Crash safety unchanged (or: power-loss behavior at each step is explained below)
  • No breaking public API change (or: described below and added to CHANGELOG)
  • Still header-only, C++14, no new dependencies
  • No board- or variant-specific code; any platform-specific code is unavoidable, isolated (adapter or guard), and explained below

Testing

Platforms tested (and how):

  • native (pio test -e native)
  • ESP32 (board / filesystem: )
  • nRF52 (board / filesystem: )

Platforms not tested, and why:

Docs

  • README / docs/ / CHANGELOG updated where user-visible behavior, build flags, configuration macros or APIs changed

…ters

Every adapter now resolves paths the same way: a path is always relative
to the adapter's root ("/a", "./a" and "a" are the same file) and the
base path says where that root is. An empty base selects the backend's
default root: the current directory on native hosts, the fallback mount
on ESP32, the filesystem root elsewhere.

- Add allocation-free Path.h (normalize/join/copy_base/persistent_mount)
- Honor the base path in the POSIX and stdio adapters
- Accept relative paths on the ESP32 LittleFS/SPIFFS/SD adapters, which
  also stops init()'s write check from reformatting on every boot
- Copy base paths into fixed adapter buffers and keep the LittleFS mount
  point in static storage, since Arduino's FS layer keeps the pointer
- Native behavior change: with the default base, absolute paths now
  resolve under the current directory; pass "/" for host-absolute paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant